git & friends
Available at lcgodoy.me/slides/2025-git/
2025-02-03
Does anyone relate to this?
Why is this useful?
Collaboration: Multiple people can work on the same project without overwriting each other’s changes.
Reverting: You can easily go back to a previous version if you make a mistake or want to try something different.
Tracking History: You can see who made what changes and when.
git?git is a distributed version control system. This means that everyone working on a project has a complete copy of the project’s history on their own computer.
It was created by Linus Torvalds (the creator of Linux) in 2005 because he needed a better way to manage the Linux kernel source code.
The distributed nature of git is a key benefit. If one person’s computer crashes, the project history is safe because everyone else has a copy.
git vs GitHub and othersThis is important: Git and GitHub are not the same thing.
GitHub is very popular, but it’s not the only option. Other platforms include:
terminalGit is primarily used from the command line or terminal. Why? Because it’s powerful and flexible. The terminal might look intimidating at first, but it’s just a way to talk to your computer using text commands.
Here are a few essential commands:
pwd (print working directory): Tells you where you are in the file system.ls (list files): Shows you the files and folders in your current directory.cd (change directory): Moves you to a different folder. cd .. goes up one level.mkdir (make directory): Creates a new folder.touch (create a file): Creates an empty file (often used for quick testing).git WorkflowThe first step is to turn a folder into a Git repository. Open your terminal, navigate to the folder, and type:
This creates a hidden .git folder inside your project folder. This folder is where Git stores all the version history.
Before you can save a version (called a commit), you need to tell Git which changes you want to include. This is called staging
To see what’s been staged, use:
Now you can save a version of your files
The -m flag lets you add a message describing the changes you made. Good commit messages are essential! They help you and others understand the history of the project.
To see the history of commits, use:
This will show you the commit messages, author, and date of each commit
If you want to work on a project that’s already on GitHub (or another platform), you can “clone” it:
This downloads a copy of the repository to your computer. You can find the URL on the platform where the project is hosted.
Pushing: Uploading your changes to a remote repository (like on GitHub).
Pulling: Downloading changes from a remote repository to your local computer.
This is how collaboration happens! We’ll cover this in more detail later.
Introduce the concept. “Think of branches as different versions of your project you can work on independently.” git branch, git checkout. Very basic example.
Requesting to merge changes from one branch into another. “This is how teams collaborate.” Mention merge conflicts briefly: “Sometimes Git can’t automatically combine changes, and you have to fix them.” Don’t go into conflict resolution in detail.
.gitignore fileExplain its purpose: Telling Git which files to ignore (e.g., temporary files, sensitive data). Show a very simple example.
Suggestive: what to ignore
pull requests
merge conflicts
gitignore
Version control helps you track changes to your files.
Git is a powerful, distributed version control system.
GitHub is a platform for hosting Git repositories.
Basic commands: init, add, commit, log, clone.
Experiment with Git! Create a simple project and try out the basic commands.
Practice is key! The more you use Git, the more comfortable you’ll become.